package com.heima.model.user.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;


/**
 * 审核状态
 */
public enum UserRealnameStatus {
    /**
     0 创建中
     1 待审核
     2 审核失败
     9 审核通过
     */
    CREATING((short)0,"创建中"),
    REVIEWED((short)1,"待审核"),
    PASS_AUTH((short)9,"审核通过"),
    FAIL_AUTH((short)2,"审核失败");

    @EnumValue
    private final Short value;
    private final String desc;

    UserRealnameStatus(short value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static UserRealnameStatus get(short value) {
        for (UserRealnameStatus c : UserRealnameStatus.values()) {
            if (c.value==value) {
                return c;
            }
        }
        return null;
    }


    @JsonValue
    public Short getValue() {
        return value;
    }

    @Override
    public String toString() {
        return this.desc;
    }


    /**
     * 检查value是否在枚举类中定义
     * @param value
     * @return
     */
    public static boolean isDefined(short value) {

        for (UserRealnameStatus c : UserRealnameStatus.values()) {
            if (c.value==value) {
                return true;
            }
        }
        return false;
    }
}
